#ifndef __MOTOR_CONTROL_H__
#define __MOTOR_CONTROL_H__

#include "gpio.h"

#define MOTOR_X_DIR_PORT P2_0
#define MOTOR_X_PUL_PORT P2_1

#define MOTOR_Y_DIR_PORT P2_2
#define MOTOR_Y_PUL_PORT P2_3

void motor_init();

typedef enum _motor_direction_t_
{
    MOTOR_DIRECTION_R,
    MOTOR_DIRECTION_L
}MOTOR_DIRECTION_T;

typedef enum _motor_gear_t_
{
    MOTOR_GEAR_NULL, //disable motor, manu can control
    MOTOR_GEAR_PARK, //speed = 0, motor hold the position
    MOTOR_GEAR_LS,
    MOTOR_GEAR_MS,
    MOTOR_GEAR_HS
}MOTOR_GEAR_T;

#define MOTOR_GEAR_LS_CNT 16332
#define MOTOR_GEAR_MS_CNT 8166
//output pul 3k, motor 10 cycles/s
#define MOTOR_GEAR_HS_CNT 4083



typedef enum _motor_index_t_
{
    MOTOR_INDEX_X,
    MOTOR_INDEX_Y
}MOTOR_INDEX_T;


void motor_shift_gear(MOTOR_INDEX_T inedx, MOTOR_DIRECTION_T dir, MOTOR_GEAR_T gear);

void motor_timer2_interrupt_handler(void);
void motor_timer3_interrupt_handler(void);



#endif
